describe('App.BillPaymentPayee', function() {
    var payee;
    beforeEach(function() {
        payee = App.BillPaymentPayee.create({
            "payeeId": 44060,
            "payeeType": "TELECOMMUNICATION",
            "payeeName": "via authorization",
            "payeeStatus": "A",
            "accountPin": 0,
            "biller": {
                "billerId": 103,
                "seqNo": 0,
                "billerName": "Axis",
                "billerAccountPin": 0,
                "billerType": "TELECOMMUNICATION",
                "billerTypeCode": "BILL_PAYMENT",
                "billerValidations": [
                    {
                        "field": "Mobile Number",
                        "fieldLocal": "Mobile Number",
                        "type": "NUMERIC",
                        "required": true,
                        "value": "083123232323",
                        "lengthMax": 30
                    }
                ]
            }
        });
    });

    it('getTransferVO', function() {
        spyOn(payee.get('billerInfo'), 'getTransferVO').andReturn({
            "billerId": 103
        })
        expect(JSON.stringify(payee.getTransferVO())).toEqual(JSON.stringify({
            "payeeId": 44060,
            "accountPin": 0,
            "biller": {
                "billerId": 103
            }
        }))
    })
});

describe('App.Biller', function() {
    var biller;

    beforeEach(function() {
        biller = App.Biller.create({
            "billerId": 103,
            "seqNo": 0,
            "billerName": "Axis",
            "billerAccountPin": 0,
            "billerType": "TELECOMMUNICATION",
            "billerTypeCode": "BILL_PAYMENT",
            "billerValidations": [
                {
                    "field": "Mobile Number",
                    "fieldLocal": "Mobile Number",
                    "type": "NUMERIC",
                    "required": true,
                    "value": "083123232323",
                    "lengthMax": 30
                }
            ]
        });
    })

    describe('getTransferVO', function() {
        it('empty validation list', function() {
            biller.set('billerValidations', []);

            expect(JSON.stringify(biller.getTransferVO())).toEqual(JSON.stringify({
                "billerId": 103,
                "seqNo": 0,
                "billerValidations": []
            }));
        });

        it('has validation', function() {
            expect(JSON.stringify(biller.getTransferVO())).toEqual(JSON.stringify({
                "billerId": 103,
                "seqNo": 0,
                "billerValidations": [
                    {
                        "field": "Mobile Number",
                        "fieldLocal": "Mobile Number",
                        "value": "083123232323"
                    }
                ]
            }));
        })
    });
    describe('getTransferVOForBillPresentment', function() {
        it('empty validation list', function() {
            biller.set('billerValidations', []);

            expect(JSON.stringify(biller.getTransferVOForBillPresentment())).toEqual(JSON.stringify({
                "billerId": 103,
                "billerName": "Axis",
                "billerType": "TELECOMMUNICATION",
                "billerTypeCode": "BILL_PAYMENT",
                "billerAccountPin": 0,
                "billerValidations": []
            }));
        });

        it('has validation', function() {
            expect(JSON.stringify(biller.getTransferVOForBillPresentment())).toEqual(JSON.stringify({
                "billerId": 103,
                "billerName": "Axis",
                "billerType": "TELECOMMUNICATION",
                "billerTypeCode": "BILL_PAYMENT",
                "billerAccountPin": 0,
                "billerValidations": [
                    {
                        "field": "Mobile Number",
                        "fieldLocal": "Mobile Number",
                        "value": "083123232323"
                    }
                ]
            }));
        })
    })
});

describe('App.BillerValidation', function() {
    describe('isFieldValueList', function() {
        it('single value in valueList', function() {
            var validation = App.BillerValidation.create({
                valueList: '1'
            });

            expect(validation.get('isFieldValueList')).toBeFalsy();
        })
        it('multiple values in valueList', function() {
            var validation = App.BillerValidation.create({
                valueList: '1;2'
            });

            expect(validation.get('isFieldValueList')).toBeTruthy();
        })
    });
    it('values', function() {
        var validation = App.BillerValidation.create({
            valueList: '1;2'
        });
        expect(validation.get('values')).toEqual(['1','2']);
    })
});

describe("App.ThirdPartyPayee",function(){
    it("currencyCode",function(){
       var currencyCode ='IDR';
       var thirdPartyTransfer = App.ThirdPartyPayee.create({
           "accountCurrency":currencyCode
       });
       expect(thirdPartyTransfer.get('currencyCode')).toEqual(currencyCode);
    });
});